package Code.Day1_20240918.com.dx.day01;

/**
 * @ClassName Test10
 * @Description 循环结构
 * @Author 12994
 * @Date 2024/9/18 21:27
 * @Version 1.0
 **/
public class Test10 {
    /**
     * while(while-do)(先判断后执行) do-while(先执行后判断) for(先判断后执行)
     */
    public static void main(String[] args) {
        int i = 10;
        while (i > 0) {
            System.out.print(i + " ");
            i--;
        }
        System.out.print("\n");

        int j = 10;
        do {
            System.out.print(j + " ");
            j--;
        } while (j > 0);
        System.out.print("\n");

        for (int k = 10; k > 0; k--) {
            System.out.print(k + " ");
        }


        i = -1;
        while (i > 0) {
            System.out.print(i + " ");
            i--;
        }
        System.out.print("\n");


        j = -1;
        do {
            System.out.print(j + " ");
            j--;
        } while (j > 0);
        System.out.print("\n");

        for (int k = -1; k > 0; k--) {
            System.out.print(k + " ");
        }


        // 数字金字塔
        for (int k = 1; k < 9; k++) {
            for (int l = 0; l < 8 - k; l++) {
                System.out.print(" ");
            }
            for (int l = 0; l < 2 * k - 1; l++) {
                System.out.print(k);
            }
            System.out.print("\n");
        }

        // 乘法表
        for (int x = 1; x < 10; x++) {
            for (int y = 1; y <= x; y++) {
                System.out.printf("%d*%d=%d\t", x, y, x * y);
            }
            System.out.print("\n");
        }
    }
}
